package com.springboot.blog.service.impl;

import com.springboot.blog.beans.Blog;
import com.springboot.blog.beans.BlogGonggao;
import com.springboot.blog.beans.PageBlog;
import com.springboot.blog.dao.BlogGgDao;
import com.springboot.blog.service.GonggaoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GonggaoServiceImpl implements GonggaoService {

    @Resource
    private BlogGgDao blogGgDao;
    @Override
    public PageBlog<BlogGonggao> page(Integer pageNo, Integer pageSize) {
        PageBlog<BlogGonggao> page = new PageBlog<BlogGonggao>();
            //设置当前页面
            page.setPageNo(pageNo);

            //求当前页的开始索引
            int begin = (page.getPageNo()-1) * pageSize;
            //求当前页数据
            List<BlogGonggao> items = blogGgDao.queryGgForItems(begin,pageSize);
            //设置当前页数据
            page.setItems(items);
        return page;
    }
}
